using System;
using System.Collections.Generic;
using System.Text;
using System.Resources;
using System.Globalization;
using System.Threading;
using System.Reflection;

namespace PengYouClient
{   
    /// <summary>
    /// Language manager class: used to get a language ressource from the language ressource file
    /// </summary>
    static public class LanguageManager
    {
        static ResourceManager lang;

        /// <summary>
        /// Define the language ressource file
        /// </summary>
        /// <param name="ress">Ressource file</param>
        static public void SetResource(string ress)
        {
            lang = new ResourceManager(ress, Assembly.GetExecutingAssembly());
        }

        /// <summary>
        /// Define the language
        /// </summary>
        /// <param name="lang">Language settings (ex: fr-FR)</param>
        static public void SetLanguage(string lang)
        {
            System.Globalization.CultureInfo cultureInfo;
            cultureInfo = new CultureInfo(lang);
            Thread.CurrentThread.CurrentCulture = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;
        }

        /// <summary>
        /// Get a language string. The return string depends of the language selected
        /// </summary>
        /// <param name="str">Name of the ressource to get</param>
        /// <returns>The ressource depending on the language</returns>
        static public string GetString(string str)
        {
            return lang.GetString(str);
        }

        static public ResourceManager Lang
        {
            get
            {
                return lang;
            }
        }
    }
}
